<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title>员工面板</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

	<script src="../../scripts/boot.js" type="text/javascript"></script>


	<style type="text/css">
		html,
		body {
			padding: 0;
			margin: 0;
			border: 0;
			height: 100%;
			overflow: hidden;
		}
	</style>
</head>

<body>

	<form id="form1" method="post">
		<div style="padding-left: 11px; padding-bottom: 5px;">
			<table style="table-layout: fixed;">
				<tr>
					<td>图书名称：</td>
					<td><input name="bookname" class="mini-textbox" required="true" emptyText="请输入图书名称" /></td>

					<td>出版社：</td>
					<td><input name="publisher" class="mini-textbox" required="true" emptyText="请输入出版社" /></td>
				</tr>

				<tr>
					<td>作者 ：</td>
					<td><input name="author" class="mini-textbox" required="true" emptyText="请输入作者" /></td>
					<td>图书类别：</td>
					<td><input name="booktype" lass="mini-combobox" url="../../data/book.txt" textField="text"
							valueField="id" name="educational" class="mini-combobox" valueField="id" textField="name"
							emptyText="请选择类型" url="" /></td>
				</tr>
				<tr>
					<td>剩余数量：</td>
					<td> <input name="remain" class="mini-spinner" minvalue="0" maxvalue="200" increment=1
							format="#,0" /></td>
				</tr>
			</table>
		</div>

		<div style="text-align: center; padding: 10px;">
			<a class="mini-button" onclick="onOk" style="width: 60px; margin-right: 20px;">确定</a> <a class="mini-button"
				onclick="onCancel" style="width: 60px;">取消</a>
		</div>
	</form>
	<script type="text/javascript">
		mini.parse();

		var form = new mini.Form("form1");

		function SaveData() {
			var o = form.getData();

			form.validate();
			if (form.isValid() == false)
				return;

			var json = mini.encode(o);
			$.ajax({
				url: "../../BookInfoAddAction?method=dopost",
				type: 'post',
				data: {
					data: json
				},
				cache: false,
				success: function (text) {
					console.log(text);
					var res = mini.decode(text);
					mini.confirm(res.msg, "新增图书", function (action) {
						CloseWindow("save");
					});

				},

				error: function (jqXHR, textStatus, errorThrown) {
					alert(jqXHR.responseText);
					CloseWindow();
				}
			});
		}

		////////////////////
		//标准方法接口定义
		function SetData(data) {
			if (data.action == "edit") {
				//跨页面传递的数据对象，克隆后才可以安全使用
				data = mini.clone(data);

				$.ajax({
					cache: false,
					success: function (text) {
						var o = mini.decode(text);
						form.setData(o);
						form.setChanged(false);

						onDeptChanged();
						mini.getbyName("position").setValue(o.position);
					}
				});
			}
		}

		function GetData() {
			var o = form.getData();
			return o;
		}
		function CloseWindow(action) {
			if (action == "close" && form.isChanged()) {
				if (confirm("数据被修改了，是否先保存？")) {
					return false;
				}
			}
			if (window.CloseOwnerWindow)
				return window.CloseOwnerWindow(action);
			else
				window.close();
		}
		function onOk(e) {
			SaveData();
		}
		function onCancel(e) {
			CloseWindow("cancel");
		}
		function onDeptChanged(e) {

			var positionCombo = mini.getbyName("position");
			var dept_id = deptCombo.getValue();
			positionCombo.setValue("");
		}
	</script>
</body>

</html>